<template>
  <div class="box">
    <header>
      <van-nav-bar title="设置" left-arrow @click-left="$router.go(-1)">
        <van-icon name="ellipsis" slot="right" />
      </van-nav-bar>
    </header>
    <div class="main">
      <div class="setupBar" @click="$router.push('/editUser')">
        <div class="left">个人资料</div>
        <div class="right">
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="setupBar">
        <div class="left">账号绑定</div>
        <div class="right">
          <span>手机/微信等</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="setupBar">
        <div class="left">修改密码</div>
        <div class="right">
          <van-icon name="arrow" />
        </div>
      </div>
      <div class="setupBar">
        <div class="left">反馈意见</div>
        <div class="right">
          <van-icon name="arrow" />
        </div>
      </div>
      <van-button type="primary" size="normal" class="outLogin" @click="outLogin">退出登录</van-button>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { mapMutations } from 'vuex'
import * as types from '@/store/mutation.types'
import { NavBar, Icon, Button } from 'vant'
Vue.use(NavBar) // 注册NavBar组件
Vue.use(Icon) // 注册Icon组件
Vue.use(Button)
export default {
  methods: {
    outLogin () {
      localStorage.setItem('loginState', '')
      localStorage.setItem('userid', '')
      this[types.CHANGE_LOGIN_STATE]({
        payload: false
      })
      this.$router.push('/user')
    },
    ...mapMutations('users', [types.CHANGE_LOGIN_STATE])
  }
}
</script>

<style lang="scss" scoped>
  .box{
    background-color: #E9ECF0;
  }
  .main{
    padding: .08rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    .setupBar{
      width: 100%;
      display: flex;
      justify-content: space-between;
      height: .56rem;
      line-height: .56rem;
      background-color: #fff;
      margin-bottom: .08rem;
      padding: 0 .16rem;
      border-radius: .04rem;
      .right{
        display: flex;
        align-items: center;
        span{
          font-size: .12rem;
        }
      }
    }
    .outLogin {
      margin-top: 50px;
      width: 30%;
      background-color: #E0E0E0;
      border: 0;
      color: #000;
    }
  }
</style>
